﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using System.Configuration;

namespace iKnow.Controllers
{
    public class UploadController : Controller
    {
        //
        // GET: /Upload/

        [AcceptVerbs(HttpVerbs.Post)]
        public String Image(HttpPostedFileBase file)
        {
            if (!Directory.Exists(Request.MapPath("~/Uploads")))
                Directory.CreateDirectory(Request.MapPath("~/Uploads"));

            var fileName = Path.Combine(Request.MapPath("~/Uploads"), Path.GetFileName(file.FileName));
            file.SaveAs(fileName);
            return @Url.Content("~/Uploads/") + Path.GetFileName(file.FileName);
        }

    }
}
